package com.zk.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zk.entity.ResultDto;
import com.zk.entity.UserEquip;
import com.zk.service.IUserEquipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ljw
 * @since 2020-11-29
 */
@RestController
@RequestMapping("/zk/user-equip")
public class UserEquipController {
    @Autowired
    IUserEquipService iUserEquipService;

    /**
     * 根据用户ID查看用户设备
     */
    @GetMapping(value = "/userid/{userId}")
    public ResultDto<IPage<UserEquip>> queryUPByUserId(
            @PathVariable Integer userId,
            @RequestParam Integer current,
            @RequestParam Integer size
    ){
        QueryWrapper<UserEquip> userEquipQueryWrapper = new QueryWrapper<>();
        userEquipQueryWrapper.eq("user_id",userId);
        IPage<UserEquip> page = new Page<>(current,size);
        return new ResultDto<>(200,"查找成功",iUserEquipService.page(page,userEquipQueryWrapper));
    }
}

